﻿<%@ Page Title="Xtablish CRM / Companies" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="Companies.aspx.cs" Inherits="Web.Company.Companies" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Con1" runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function OnClientClose(oWnd, args) { }
            function ClearClick() {
                document.getElementById('<%= txtCompanyName.ClientID %>').value = "";
                document.getElementById('<%= txtPrimaryEmail.ClientID %>').value = "";
                document.getElementById('<%= txtContactNumber.ClientID %>').value = "";
                var atcombo = $find("<%= ddlAssignedTo.ClientID %>");
                setSelectedIndex(atcombo);
            }
            function setSelectedIndex(combo) {
                combo.trackChanges();
                combo.get_items().getItem(0).select();
                combo.updateClientState();
                combo.commitChanges();
            }
            function isPressEnter(evt) {
                var charCode = (evt.which) ? evt.which : event.keyCode
                if (charCode == 13) {
                    var clickButton = document.getElementById('<%= btnSearch.ClientID %>');
                    clickButton.click();
                }
            }
        </script>
    </telerik:RadCodeBlock>
    <div class="register">
        <div class="container-fluid">
            <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="row">
                    <div class="panel panel-default">
                        <div class="panel-heading" role="tab" id="headingOne">
                            <h4 class="panel-title">
                                <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">Search <i class="glyphicon glyphicon-circle-arrow-down" style="display: none;"></i><i class="glyphicon glyphicon-circle-arrow-up"></i>
                                </a>
                            </h4>
                        </div>
                        <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                            <div class="panel-body">
                                <div class="firstrow">
                                    <div class="edit-form">
                                        <div class="control-group">
                                            <div class="col-md-4 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Company Name </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <asp:TextBox ID="txtCompanyName" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-4 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Contact Number </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <asp:TextBox ID="txtContactNumber" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-4 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Email </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <asp:TextBox ID="txtPrimaryEmail" runat="server" class="form-control" onkeypress="isPressEnter(event)"  />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                        <div class="control-group">
                                            <div class="col-md-4 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Date Created From </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <telerik:RadDatePicker ID="dpDateCreatedFrom" runat="server" Width="50%">
                                                            <DateInput ReadOnly="true" ID="RadDateInput1" runat="server">
                                                            </DateInput>
                                                            <Calendar ReadOnly="true" ID="Calendar1" runat="server" UseColumnHeadersAsSelectors="False"
                                                                UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                                <SpecialDays>
                                                                    <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday">
                                                                    </telerik:RadCalendarDay>
                                                                </SpecialDays>
                                                            </Calendar>
                                                        </telerik:RadDatePicker>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-4 distance-control">
                                                <div class="col-md-4">
                                                    <label class="control-label">Date Created To </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <telerik:RadDatePicker ID="dpDateCreatedTo" runat="server" Width="50%">
                                                            <DateInput ReadOnly="true" ID="DateInput2" runat="server">
                                                            </DateInput>
                                                            <Calendar ReadOnly="true" ID="Calendar2" runat="server" UseColumnHeadersAsSelectors="False"
                                                                UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                                <SpecialDays>
                                                                    <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday">
                                                                    </telerik:RadCalendarDay>
                                                                </SpecialDays>
                                                            </Calendar>
                                                        </telerik:RadDatePicker>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-4 distance-control" id="divAssignTo" runat="server">
                                                <div class="col-md-4">
                                                    <label class="control-label">Assign To </label>
                                                </div>
                                                <div class="col-md-8">
                                                    <div class="controls">
                                                        <telerik:RadComboBox ID="ddlAssignedTo" runat="server" class="form-control"
                                                            Width="80%" Filter="StartsWith" MaxHeight="700px" />
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="popup-btn">
                                    <div class="col-md-12 btn-edit">
                                        <button id="btnSearch" type="button" class="btn btn-defaul" runat="server" onserverclick="btnSearch_ServerClick">
                                            <img src="../Images/search.png" style="width: 20px; height: 20px" />
                                            Search
                                        </button>
                                        <div id="validation_dialog" style="display: none">
                                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                                        </div>
                                        <button class="btn btn-defaul" type="button" onclick="ClearClick();return false;">
                                            <img src="../Images/clear.png" style="width: 20px; height: 20px" />
                                            Clear
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <%--end row--%>
                <div class="row">
                    <div class="edit-form highlight">
                        <div class="control-group">
                            <h4>Companies</h4>
                        </div>
                        <div class="col-md-12 combobox-email">
                            <div class="col-md-5 btn-edit">
                                <button id="btnAddCompany" type="button" class="btn btn-defaul" runat="server" onserverclick="btnAddCompany_ServerClick">
                                    <img src="../Images/add.png" style="width: 16px; height: 16px" />
                                    Add Company
                                </button>
                                <button id="lbtnExportToCSV" type="button" runat="server" class="btn btn-defaul" onserverclick="lbtnExportToCSV_ServerClick">
                                    <img src="../Images/CSV.png" style="width: 16px; height: 16px;" />
                                    Export to Excel
                                </button>
                                <button id="lbtnImport" type="button" runat="server" class="btn btn-defaul" onserverclick="lbtnImport_ServerClick">
                                    <img src="../Images/import.png" style="width: 16px; height: 16px;" />
                                    Import from Excel
                                </button>
                            </div>
                            <div class="col-md-4" style="vertical-align: central; padding-top: 6px; padding-bottom: 6px">
                                <label class="control-label" style="font-weight: 700">Email Template </label>
                            </div>
                            <div class="col-md-3" style="padding-right: 0">
                                <div class="controls">
                                    <telerik:RadComboBox ID="ddlEmailTemplate" runat="server" class="form-control" DataTextField="TEMPLATE_NAME" DataValueField="ID"
                                        Width="100%" Filter="StartsWith" MaxHeight="700px" />
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                        <div style="width: 100%">
                            <telerik:RadGrid ID="RadGrid1" ShowStatusBar="True" runat="server" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="True" ClientSettings-Scrolling-AllowScroll="false"
                                AutoGenerateColumns="False" GridLines="None" Width="100%" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCreated="RadGrid1_ItemCreated"
                                OnPreRender="RadGrid1_PreRender" OnItemCommand="RadGrid1_ItemCommand">
                                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="false">
                                    <Selecting AllowRowSelect="false" />
                                </ClientSettings>
                                <GroupHeaderItemStyle BackColor="red" />
                                <MasterTableView PageSize="10" NoDetailRecordsText="No records" NoMasterRecordsText="No records" ShowHeader="true" DataKeyNames="ID" TableLayout="Fixed" >
                                    <Columns>
                                        <telerik:GridTemplateColumn HeaderText="Seq" UniqueName="TemplateColumn1">
                                            <ItemTemplate>
                                                <asp:Label ID="lblSeq" runat="server" Text="<%# RadGrid1.CurrentPageIndex*RadGrid1.MasterTableView.PageSize + RadGrid1.Items.Count+1 %>">
                                                </asp:Label>
                                            </ItemTemplate>
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="Center" Width="5%" />
                                            <ItemStyle HorizontalAlign="Center" Width="5%" />
                                            <FooterStyle HorizontalAlign="center" Width="5%" BackColor="LightBlue" />
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridBoundColumn DataField="ORGANIZATION_NAME" HeaderText="Company Name" UniqueName="ORGANIZATION_NAME" SortExpression="ORGANIZATION_NAME">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="14%" />
                                            <ItemStyle Wrap="false" HorizontalAlign="Left" Width="14%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridHyperLinkColumn SortExpression="COMPANY_WEBSITE" DataTextFormatString="{0}"
                                            DataNavigateUrlFields="COMPANY_WEBSITE" UniqueName="COMPANY_WEBSITE" DataNavigateUrlFormatString="{0}"
                                            HeaderText="Company Website" DataTextField="COMPANY_WEBSITE" Target="_blank">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="14%" />
                                           <ItemStyle Wrap="false" HorizontalAlign="left" Width="14%" CssClass="hyperlink" />
                                        </telerik:GridHyperLinkColumn>
                                        <telerik:GridBoundColumn DataField="CONTACT_NUMBER" HeaderText="Contact Number" UniqueName="CONTACT_NUMBER" SortExpression="CONTACT_NUMBER">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="8%" />
                                           <ItemStyle Wrap="false" HorizontalAlign="left" Width="8%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn HeaderText="Email" UniqueName="PRIMARY_EMAIL">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="14%" />
                                           <ItemStyle Wrap="false" HorizontalAlign="left" Width="14%" />
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbtnSendEmail" runat="server" Text='<%# Eval("PRIMARY_EMAIL") %>' OnClick="sendEmail_Click" ForeColor="Blue" />
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridBoundColumn DataField="OFFICE_CITY" HeaderText="Office City" UniqueName="OFFICE_CITY" SortExpression="OFFICE_CITY">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                           <ItemStyle Wrap="false" HorizontalAlign="center" Width="7%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="OFFICE_COUNTRY" HeaderText="Office Country" UniqueName="OFFICE_COUNTRY" SortExpression="OFFICE_COUNTRY">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                           <ItemStyle Wrap="false" HorizontalAlign="center" Width="7%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="MEMBER_OF" HeaderText="Subsidary" UniqueName="MEMBER_OF" SortExpression="MEMBER_OF">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                           <ItemStyle Wrap="false" HorizontalAlign="Left" Width="10%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="DATE_ENTERED" HeaderText="Date Created" UniqueName="DATE_ENTERED" SortExpression="DATE_ENTERED" DataFormatString="{0:d}" DataType="System.DateTime">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" Font-Size="12px" />
                                            <ItemStyle HorizontalAlign="center" Width="7%" Font-Size="12px" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ASSIGN_TO" HeaderText="Assign To" UniqueName="ASSIGN_TO" SortExpression="ASSIGN_TO">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                            <ItemStyle Wrap="false" HorizontalAlign="Left" Width="7%" />
                                        </telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn AllowFiltering="false" HeaderText="TOOLS" UniqueName="TOOLS">
                                            <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="7%" />
                                            <ItemStyle HorizontalAlign="center" Width="7%" />
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbtnEdit" runat="server" CommandName="Edit" ToolTip="Edit">
                                                    <image src="../Images/edit.png" style="width: 16px; height: 16px"/>
                                                </asp:LinkButton>
                                                &nbsp
                                                <asp:LinkButton ID="lbtnDelete" runat="server" ToolTip="Delete" CommandName="Delete" OnClientClick="return radConfirmDelete(this, 'Are you sure you want to delete this company ?');">
                                                    <image src="../Images/delete.png" style="width: 16px; height: 16px"/>
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                    </Columns>
                                    <PagerStyle PageSizes="5,10,20,50" PagerTextFormat="{4}<strong>{5}</strong> companies matching your search criteria"
                                        PageSizeLabelText="Companies per page:" AlwaysVisible="true" />
                                </MasterTableView>
                                <PagerStyle Mode="NumericPages"></PagerStyle>
                            </telerik:RadGrid>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
